package com.foundersoftware.commons.organization.service;
import com.foundersoftware.commons.organization.ObjectAlreadyExistsException;
import com.foundersoftware.commons.organization.ObjectNotFoundException;
import com.foundersoftware.commons.organization.OrganizationException;
import com.foundersoftware.commons.organization.dao.IOrganizationDAO;
import com.foundersoftware.commons.organization.model.AbstractOrganizationObject;
import com.foundersoftware.commons.organization.model.Employee;
import com.foundersoftware.commons.organization.model.EmployeeType;
import com.foundersoftware.commons.organization.model.OrganizationUnit;
import com.foundersoftware.commons.organization.model.OrganizationUnitType;
import com.foundersoftware.commons.organization.model.Position;
import com.foundersoftware.commons.organization.model.PositionType;
import com.foundersoftware.commons.organization.model.Responsibility;
import com.foundersoftware.commons.organization.model.Role;
import com.foundersoftware.commons.organization.model.RoleType;
import com.foundersoftware.commons.organization.model.Type;
import com.foundersoftware.commons.organization.model.WorkGroup;
import com.foundersoftware.commons.organization.model.WorkGroupType;

import java.rmi.RemoteException;
import java.util.Set;

public interface IOrganizationService  {
    void setOrganizationStore(IOrganizationDAO orgStore);

     EmployeeType createEmployeeType(EmployeeType employeeType);
     Employee createEmployee(Employee employee) throws ObjectAlreadyExistsException;
     OrganizationUnitType createOrganizationUnitType(OrganizationUnitType organizationUnitType)throws ObjectAlreadyExistsException;
     OrganizationUnit createOrganizationUnit(OrganizationUnit organizationUnit)throws ObjectAlreadyExistsException;
     PositionType createPositionType(PositionType positionType)throws ObjectAlreadyExistsException;
     Position createPosition(Position position)throws ObjectAlreadyExistsException;
     RoleType createRoleType(RoleType roleType)throws ObjectAlreadyExistsException;
     Role createRole(Role role)throws ObjectAlreadyExistsException;
     WorkGroupType createWorkGroupType(WorkGroupType workGroupType)throws ObjectAlreadyExistsException;
     WorkGroup createWorkGroup(WorkGroup workGroup)throws ObjectAlreadyExistsException;
     Responsibility createResponsibility(Responsibility responsibility)throws ObjectAlreadyExistsException;
     
     void addEmployeeToOrganizationUnit(Employee employee,OrganizationUnit organization)throws ObjectNotFoundException;
     void addEmployeesToOrgainzationUnti(Set<Employee> employees,OrganizationUnit organization);
     
     void addEmployeeToWorkGroup(Employee employee,WorkGroup workGroup)throws ObjectNotFoundException;
     void addEmployeesToWorkGroup(Set<Employee> employees,WorkGroup workGroup)throws ObjectNotFoundException;
    
     void addPositionToOrganizationUnit(Position position, OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     void addPositionsToOrganizationUnit(Set<Position> positions, OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     void addRoleToWorkGroup(Role role, WorkGroup workGroup)throws ObjectNotFoundException;
     void addRolesToWorkGroup(Set<Role> roles, WorkGroup workGroup)throws ObjectNotFoundException;
     void addResponsibilityToPosition(Responsibility responsibility , Position position)throws ObjectNotFoundException;
     void addResponsibilitiesToPosition(Set<Responsibility> responsibilities , Position position)throws ObjectNotFoundException;
     void addResponsibilityToRole(Responsibility responsibility, Role role)throws ObjectNotFoundException;
     void addResponsibilitiesToRole(Set<Responsibility> responsibilities, Role role)throws ObjectNotFoundException;
     void assignPositionToEmployee(Position position,Employee employee)throws ObjectNotFoundException;
     void assignPositionsToEmployee(Set<Position> positions,Employee employee)throws ObjectNotFoundException;
     void assignRoleToEmployee(Role role, Employee employee,WorkGroup workGroup)throws ObjectNotFoundException;
     void assignRolesToEmployee(Set<Role> roles, Employee employee,WorkGroup workGroup)throws ObjectNotFoundException;

     void deleteEmployee(Employee employee)throws ObjectNotFoundException;
     void deleteOrganizationUnitType(OrganizationUnitType organizationUnitType)throws ObjectNotFoundException;
     void deleteOrganizationUnit(OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     void deletePostionType(PositionType positionType)throws ObjectNotFoundException;
     void deletePosition(Position position)throws ObjectNotFoundException;
     void deleteRoleType(Type roleType)throws ObjectNotFoundException;
     void deleteRole(Role role)throws ObjectNotFoundException;
     void deleteWorkGroupType(WorkGroupType workGroupType)throws ObjectNotFoundException;
     void deleteWorkGroup(WorkGroup workGroup)throws ObjectNotFoundException;
     void deleteResponsibility(AbstractOrganizationObject responsibility)throws ObjectNotFoundException;


     void removeEmployeeFromOrganizationUnit(Employee employee,OrganizationUnit organization)throws ObjectNotFoundException;
     void removeEmployeeFromWorkGroup(Employee employee,WorkGroup workGroup)throws ObjectNotFoundException;
     void removePositionFromOrganiztionUnit(Position position, OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     void removeRoleFromWorkGroup(Role role, WorkGroup workGroup)throws ObjectNotFoundException;
     void removeResponsibilityFromPosition(AbstractOrganizationObject responsibility , Position position)throws ObjectNotFoundException;
     void removeResponsibilityFromRole(AbstractOrganizationObject responsibility, Role role)throws ObjectNotFoundException;
     void removeRoleFromEmployee(Role role, Employee employee,WorkGroup workGroup)throws ObjectNotFoundException;
     void removePositionFromEmployee(Position position, Employee employee)throws ObjectNotFoundException;


     Employee updateEmployee(Employee employee)throws ObjectNotFoundException;
     OrganizationUnitType updateOrganizationUnitType(OrganizationUnitType organizationUnitType)throws ObjectNotFoundException;
     OrganizationUnit updateOrganizationUnit(OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     PositionType updatePostionType(PositionType positionType)throws ObjectNotFoundException;
     Position updatePosition(Position position)throws ObjectNotFoundException;
     Type updateRoleType(Type roleType)throws ObjectNotFoundException;
     Role updateRole(Role role)throws ObjectNotFoundException;
     WorkGroupType updateWorkGroupType(WorkGroupType workGroupType)throws ObjectNotFoundException;
     WorkGroup updateWorkGroup(WorkGroup workGroup)throws ObjectNotFoundException;
     AbstractOrganizationObject updateResponsibility(AbstractOrganizationObject responsibility)throws ObjectNotFoundException;



     Employee getEmployee(String employeeid)throws ObjectNotFoundException;
     OrganizationUnitType getOrganizationUnitType(String organiztionUnitTypeId)throws ObjectNotFoundException;
     OrganizationUnit getOrganizationUnit(String organizationUnitId)throws ObjectNotFoundException;
     PositionType getPostionType(String positionTypeId)throws ObjectNotFoundException;
     Position getPosition(String positionId)throws ObjectNotFoundException;
     RoleType getRoleType(String roleTypeId)throws ObjectNotFoundException;
     Role getRole(String roleId)throws ObjectNotFoundException;
     WorkGroupType getWorkGroupType(String workGroupTypeId)throws ObjectNotFoundException;
     WorkGroup getWorkGroup(String workGroupId)throws ObjectNotFoundException;
     Responsibility getResponsibility(String responsibilityId)throws ObjectNotFoundException;

     Employee[] getAllEmployees()throws OrganizationException,RemoteException;


     OrganizationUnitType[] getAllOrganizationUnitTypes()throws OrganizationException,RemoteException;


     OrganizationUnit[] getAllOrganizationUnits()throws OrganizationException,RemoteException;
     PositionType[] getAllPositionTypes()throws OrganizationException,RemoteException;
     Position[] getAllPositions()throws OrganizationException,RemoteException;
     RoleType[] getAllRoleTypes()throws OrganizationException,RemoteException;
     Role[] getAllRoles()throws OrganizationException,RemoteException;
     WorkGroupType[] getAllWorkGroupTypes()throws OrganizationException,RemoteException;
     WorkGroup[] getAllWorkGroups()throws OrganizationException,RemoteException;
     Responsibility[] getAllResponsibilities()throws OrganizationException,RemoteException;

     Employee[] getEmployeesOfOrganizationUnit(OrganizationUnit organizationUnit,boolean isDirect)throws ObjectNotFoundException;
     OrganizationUnit[] getChildOrganizationUnits(OrganizationUnit superOrganizationUnit)throws ObjectNotFoundException;
     Position[] getPositionsOfOrganizationUnit(OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     Role[] getRolesOfWorkGroup(WorkGroup workGroup)throws ObjectNotFoundException;
     Role[] getRolesOfEmployee(Employee employee, WorkGroup workGroup)throws ObjectNotFoundException;
     Position getPositionsOfEmployee(Employee employee)throws ObjectNotFoundException;
     Responsibility[] getResponsibilitiesOfRole(Role role)throws ObjectNotFoundException;
     Responsibility[] getResponsibilitiesOfPosition(Position position)throws ObjectNotFoundException;
     OrganizationUnit getOrganizationUnitOfEmployBelongTo(String employeeId)throws ObjectNotFoundException;
     boolean isEmployeeBelongsToOrganizationUnit(Employee employee, OrganizationUnit organizationUnit)throws ObjectNotFoundException;
     boolean isEmployeeBelongsToWorkGroup(Employee employee, WorkGroup workGroup)throws ObjectNotFoundException;
     boolean isOrganizationUnitHasPosition(OrganizationUnit organizationUnit, Position position)throws ObjectNotFoundException;
     boolean isWorkGroupHasRole(WorkGroup workGroup, Role role)throws ObjectNotFoundException;
     boolean isPositionHasResponsibility(Position position, AbstractOrganizationObject responsibility)throws ObjectNotFoundException;
     boolean isRoleHasResponsibility(Role role,AbstractOrganizationObject responsibility)throws ObjectNotFoundException;
     boolean isEmployeeHasRoleInsideWorkGroup(Employee employee, Role role, WorkGroup workGroup)throws ObjectNotFoundException;
     boolean isEmployeeHasPosition(Employee employee, Position position)throws ObjectNotFoundException;
    }
